<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).keypress(function(e) {
	if (e.which == 13) {
		add_checkin_dormitory();
	}
});

function submit1(){	
	console.log("submit");
	var member_length=$('#checkin_table').find("input").length/4;
	var result=[];
	var member='';
	var cour_id=$("input[name='cour_id']").val();
	for(var i=1;i<member_length;i++){
		var result="input[name='"+i+"']:checked";
		var stu_id="#stu_"+i;
		
		member+=$(stu_id).text()+","+$(result).val()+"&&";

	}
	console.log(member);
	$.ajax({
		url:'http://localhost:8080/Hello/docheck.do',
		type:'post',
		dataType : 'json',
		data:{
			"result":member,
			"cour_id":cour_id
		},
		success:function(data){
			alert("提交成功");
		},
		error:function(data){
			alert("fail");
		}
	})
}


function checkup()
{
  if(window.confirm("确定要提交吗？"))
  {
   return true;
  }
  else
  {
    return false;
  }
}
</script>

<body>
	<p>${cd.year }学年${cd.team }第${cd.week }周 &nbsp; 课程节次：${cd.count }班级名字：${cd.banjiname }
		课程名字${cd.clazzNname } 教师名称： ${cd.teacher }</p>
		
	
		<table id=checkin_table>
			<tr>
				<th>序号</th>
				<th>学号</th>
				<th>姓名</th>
				<th>是否定制班</th>
				<th>出勤</th>
				<th>迟到</th>
				<th>请假</th>
				<th>旷课</th>
			</tr>
			<c:forEach var="stu" items="${studs }" varStatus="status">
			<tr>
				<td>${status.count}</td>
				<td id="stu_${ status.count}">${ stu.id}</td>
				<td>${ stu.name}</td>
				<td><input type="radio" name="result" id="${ stu.id}" value=""/></td>
				<td><input type="radio" name="${ status.count}" checked value="出勤"/></td>
				<td><input type="radio" name="${ status.count}" value="迟到"/></td>
				<td><input type="radio" name="${ status.count}" value="请假"/></td>
				<td><input type="radio" name="${ status.count}" value="旷课"/></td>
			</tr>
			</c:forEach>
			<tr><td>
			<input type="hidden" name="cour_id" value="${cd.id }" />
			</td></tr>
			<tr>
				<td colspan="8"><button id="button" onclick="submit1()" >提交</button></td>
			</tr>
		</table>
	
</body>
</html>